-- rein logisches object
Item = {          name = 'a item',
                  typus = 'default',
                  icon = 'a path',
									sprite = "",
                  image = 'sth. that changes the chacarcters look',
                                    
                  requirement = { 
                            str = 0, 
                            int = 0,
                            dex = 0,
                            agi = 0,
                            level = 0
                                },
                   
                  bonus = { str = {0,0},
                            int = {0,0},
                            dex = {0,0},
                            agi = {0,0},      
                            level = {0,0}, -- does not realy increase your lv but allows you to ware items whcih would require i higher lv tha your actual lv
                          
                           },                    
                         
                 use = 'a function' -- primaryely this feeld is used by usabal items like potions, but it also can contain a special abilety of an equipment item
                  }


function Item:new(o) -- creats a new item class
                  
  o = o or {}
	o.requirement = o.requirement or {}
	o.bonus = o.bonus or {}
	
  setmetatable(o, self)
  self.__index = self
  
  setmetatable(o.requirement, self.requirement)
  self.requirement.__index = self.requirement
  
  setmetatable(o.bonus, self.bonus)
  self.bonus.__index = self.bonus
    
  return o

end
        
        
function Item:create(o) 
  o = {bonus = {}}
	for k,v in pairs(Item.bonus) do
		if self.bonus[k][2] then
 			o.bonus[k] = math.random(self.bonus[k][1],self.bonus[k][2])
		else
			o.bonus[k] = 0
		end
	end
 return self:new(o)
                                                            
  
end

-- erlaubt es einem aus einem Item, ein item im ingame zu machen
ItemGameelement =  Gameelement:new{
	item = {},
	image = {},
	stateList = {
		lieAbout = {
			name = "lii about",
			actions = {
				function(t)
					if gameelementCollision(hero, t) then --TODO: not just check if hero 
	
						hero:getItem(t.item)
						t:changeState(t.stateList.destroy)
					end
				end
				
			}
		}
	}
}
ItemGameelement.currentState = ItemGameelement.stateList.lieAbout



